home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / os2 / pccts.zip / DLG.H < prev    next >
C/C++ Source or Header  |  1992-12-08  |  5KB  |  137 lines

  1. /* dlg header file
  2.  *
  3.  * Will Cohen
  4.  * 8/18/90
  5.  */
  6. #include "set.h"
  7.  
  8. #define TRUE    1
  9. #define FALSE    0
  10.  
  11. /***** output related stuff *******************/
  12. #define IN    input_stream
  13. #define OUT    output_stream
  14.  
  15. #define MAX_MODES    50    /* number of %%names allowed */
  16. #define MAX_ON_LINE    10
  17.  
  18. /* these macros allow the size of the character set to be easily changed */
  19. /* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */
  20. #define MIN_CHAR (-1)    /* lowest possible character possible on input */
  21. #define MAX_CHAR 255    /* highest possible character possible on input */
  22. #define CHAR_RANGE ((MAX_CHAR) - (MIN_CHAR))
  23.  
  24. /* indicates that the not an "array" reference */
  25. #define NIL_INDEX 0
  26.  
  27. /* size of hash table used to find dfa_states quickly */
  28. #define HASH_SIZE 200
  29.  
  30. #define nfa_node struct _nfa_node
  31. nfa_node {
  32.     nfa_node    *left,*right;    /* for binary tree storage of array */
  33.     int        node_no;
  34.     int        nfa_set;
  35.     int        accept;    /* what case to use */
  36.     nfa_node    *trans[2];
  37.     set        label;    /* one arc always labelled with epsilon */
  38. };
  39.  
  40. #define dfa_node struct _dfa_node
  41. dfa_node {
  42.     dfa_node    *left,*right;    /* for binary tree storage of array */
  43.     int        node_no;
  44.     int        dfa_set;
  45.     int        alternatives;    /* used for interactive mode */
  46.                     /* are more characters needed */
  47.     int        done;
  48.     set        nfa_states;
  49.     int        trans[1];/* size of transition table depends on
  50.                   * number of classes required for automata.
  51.                   */
  52.  
  53.  
  54. };
  55.  
  56. /******** macros for accessing the NFA and DFA nodes ****/
  57. #define NFA(x)    index_nfa(x)
  58. #define DFA(x)    index_dfa(x)
  59. #define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
  60. #define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
  61.  
  62. /******** wrapper for memory checking ***/
  63. /*#define malloc(x)    dlg_malloc((x),__FILE__,__LINE__)*/
  64. extern char *dlg_malloc();    /* wrapper for memory allocations */
  65.  
  66. /*#define calloc(x,y)    dlg_calloc((x),(y),__FILE__,__LINE__)*/
  67. extern char *dlg_calloc();    /* wrapper for memory allocations */
  68.  
  69. /******** antlr attributes *************/
  70. typedef struct {
  71.     char letter;
  72.     nfa_node *l,*r;
  73.     set label;
  74.     } Attrib;
  75.  
  76. #define zzcr_attr(attr, token, text) {                    \
  77.     (attr)->letter = text[0]; (attr)->l = NULL;            \
  78.     (attr)->r = NULL; (attr)->label = empty;            \
  79. }
  80. #define zzd_attr(a)    set_free((a)->label);
  81.  
  82. /******************** Variable ******************************/
  83. extern char    version[];    /* tells what version this is */
  84. extern char    *file_str[];    /* file names being used */
  85. extern int    err_found;    /* flag to indicate error occured */
  86. extern int    action_no;    /* last action function printed */
  87. extern int    func_action;    /* should actions be turned into functions?*/
  88. extern set    used_chars;    /* used to label trans. arcs */
  89. extern set    used_classes;    /* classes or chars used to label trans. arcs */
  90. extern int    class_no;    /* number of classes used */
  91. extern set    class[];    /* shows char. in each class */
  92. extern set    normal_chars;    /* mask off unused portion of set */
  93. extern int    comp_level;    /* what compression level to use */
  94. extern int    interactive;    /* interactive scanner (avoid lookahead)*/
  95. extern int    mode_counter;    /* keeps track of the number of %%name */
  96. extern int    dfa_basep[];    /* start of each group of dfa */
  97. extern int    dfa_class_nop[];/* number of transistion arcs in */
  98.                 /* each dfa in each mode */
  99. extern int    nfa_allocated;
  100. extern int    dfa_allocated;
  101. extern nfa_node    *nfa_array;    /* start of nfa "array" */
  102. extern dfa_node    *dfa_array;    /* start of dfa "array" */
  103. extern int    operation_no;    /* unique number for each operation */
  104. extern FILE    *input_stream;    /* where description read from */
  105. extern FILE    *output_stream; /* where to put the output */
  106. extern FILE    *mode_stream;    /* where to put the mode output */
  107. extern char    *mode_file;    /* name of file for mode output */
  108. extern int    gen_ansi;    /* produce ansi compatible code */
  109. extern int    case_insensitive;/* ignore case of input spec. */
  110.  
  111. /******************** Functions ******************************/
  112. #ifdef __STDC__
  113. extern set    reach(set, register int);
  114. extern set    closure(set *);
  115. extern dfa_node *new_dfa_node(set);
  116. extern nfa_node *new_nfa_node();
  117. extern dfa_node *dfastate(set);
  118. extern dfa_node *index_dfa(register int);
  119. extern nfa_node *index_nfa(register int);
  120. extern dfa_node *nfa_to_dfa(nfa_node *);
  121. extern        internal_error(char *, char *, int);
  122. extern FILE    *read_stream(char *);    /* opens file for reading */
  123. extern FILE    *write_stream(char *);    /* opens file for writing */
  124. #else
  125. extern set    reach();
  126. extern set    closure();
  127. extern dfa_node *new_dfa_node();
  128. extern nfa_node *new_nfa_node();
  129. extern dfa_node *dfastate();
  130. extern dfa_node *index_dfa();
  131. extern nfa_node *index_nfa();
  132. extern dfa_node *nfa_to_dfa();
  133. extern        internal_error();
  134. extern FILE    *read_stream();        /* opens file for reading */
  135. extern FILE    *write_stream();    /* opens file for writing */
  136. #endif
  137.